The first kind:?ROR CodeClass Foocontroller ? ? Protect_from_forgery:except =: Index?????? # can disable CSRF protection on controller-by-controller basis:?? ? Skip_before_filter:verify_authenticity_token?End?Class Foocontroller ????The second kind:?Modify configuration file config\environments\development.rb?????ROR Code# Disable Request forgery protection in development environment???? config.action_controller.allow_forgery_protection = False???Then restart the server?????The Third Kind:?Join
Follow the examples in Agile Web Development in the third edition.
The procedure is as follows:
Rails2.0 enabled in environment. rb
Config. action_controller.session_store =: active_record_store
# Use the database for sessions instead of the cookie-
-Problem Solving (ii) ACTIVEMODEL::FORBIDDENATTRIBUTESERROR errors caused by rails4.0create
Ruby-Problem Solving (iii) coding errors causing the inability to display (1)
Ruby-Problem Solving (iv) coding errors causing the inability to display (2)
Ruby--Problem Solving (v) page back to jump
Ruby--Problem Solving (vi) link_to to destroy not working
Ruby-Problem Solving (vii) Actioncontroller::invalidauthenticitytoken solutions
Ru
error occurs.Actioncontroller: invalidauthenticitytoken
Solution: The application_controller.rb file cannot have a foreign key protection method.
protect_from_forgery(:except =>[:login,:logoutcas,:logout,:filter,:single_sign_out])
skip_before_filter :verify_authenticity_token
Or modify the configuration file config/environments/development. RB.
# Disable Request Forgery protection in Development Environment
Config. action_controller.allo
back as a variable of Ajax to prevent actioncontroller::Invalidauthenticitytoken error.
Then add the followingCode, Surrounded by a selected limb. Only xhr requests call them:
The main point is that this is a pentagon, so we first use 360/5 to get the angle of each point offset, and we get the coordinates of each point through COs and sin.
// Use the radius as the oblique side of the triangle // The oblique side * returns the coordinate of the P
One major improvement of rails 3 is unobtrusive.Javascript(Non-intrusive JavaScript) to implementCode. For example:
1
Convert:
AHref= "/Products/8"Data-confirm= "Are you sure? "Data-Method= "Delete"REL= "Nofollow">DestroyA>
No additional JS Code is available, but the data-YesHTML5So it is still a little difficult to run this code. On Windows, click destroy to jump to show action.
Reference:The reason that the link isn't working is that we don't have the relevant JavaScript files referen
An iterative development of the site will inevitably exist bugs, when the customer experience is very bad, in order to solve this problem, can be generated when class error, trigger jump to the unified Tip page, and to the developer to send an error message, improve the test capability and user experience. The following is the core approach; The following code is added to the Applicationcontroller, and the class error for different rails versions changes slightly.
Copy Code code as follo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.